This page last changed on Feb 28, 2006 by glaforge.
Advanced Topics
Grails Artifacts
Grails takes the separation of concerns approach splitting a Grails application in three layers or tiers:
- web tier: presentation logic resides here. Artifacts are:
- views
- controllers
- page flows
- models
- command objects
- validators
- business logic tier: business logic controlled by a middle tier that supports transactional demarcation. Artifacts are:
- persistence tier: operates within the transactional boundries of the business tier and is also controlled by a middle tier, deals with persistence details. Artifacts are:
- domain class persistence methods
- data sources
- ORM tool sessions and factories.
Grails requires users to provide some of the artifacts in the above list. Configuration of these artifacts is taken care of by Grails based on a number of conventions per artifact type.
Injection behavior
Whenever injection of beans is supported the default behaviour is injection by type.
@Property CountryService countryService
In this example a bean of type CountryService is required.
To enable injection by name add a "byName" property to the class and set it to true:
@Property boolean byName = true
In the example above this would require a bean named "countryService".
When beans should not be available for injection create an "available" property and set it false. This property can be used to avoid type conflicts.
@Property boolean available = true
Configurational properties
When property names are reserved for the configuration of specific artifacts in Grails other properties with the same name but not the same type are ignored.
class SomeService {
@Property boolean transactional = false
@Property String transactional = "false" }
|